package top.kaoshanji.p1ch04a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
 * 代码清单 p1ch04a-13：DecimalFormat类的使用示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/15 19:51
 */
public class NumberFormatExample02 {

    private static final Logger logger = LogManager.getLogger(NumberFormatExample02.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p1ch04a-13：DecimalFormat类的使用示例...");

        NumberFormat format = NumberFormat.getNumberInstance();
        DecimalFormat df = null;
        if (format instanceof DecimalFormat) {
            df = (DecimalFormat) format;
        } else {
            df = new DecimalFormat();
        }

        df.applyPattern("000.###");
        String strFormat = df.format(3.14);
        logger.info("...strFormat:{}...", strFormat);

    }


}
